import React, { Component } from 'react';
import './Login.css'
import WebSocketClient from '../im_sdk';

class Login extends Component {

    componentDidMount () {
        // this.socket = new WebSocketClient();
    }
    onLogin () {
        // this.props.history.push({
        //     pathname: '/'
        // })
        // 通过扫码或账号密码登录获取token
        const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoyMTcsInBsYXRmb3JtIjoiaW9zIn0.JLx_CFhFIdpEnUBJUxjB0BQ-H3PAeeFm-fd1jG0Dun8'
        // 1. token与当前会话绑定
        // 2. 绑定成功则跳转至主页面
        // this.ws.send('/v1/session/bind/uid/by/token', {token}, (data) => {
        //     this.props.history.push({
        //         pathname: '/conversation',
        //         state: {
        //             socket: this.socket,
        //         }
        //     })
        // })
        this.props.history.push({pathname: '/conversation', state: { socket: {a: 1}}})
    }

    render() {
        return (
            <div className='login'>
                <div className='qrcode'></div>
                <button onClick={this.onLogin.bind(this)}>Login</button>
            </div>
        )
    }
}


export default Login;
